<%@ page contentType="text/html; charset=utf-8"%>
<%@ include file="/global/jsp-header.jsp"%>
<!DOCTYPE HTML>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html">
		<title>新增菜单</title>
		<%@ include file="/global/html-header.jsp"%>
<script type="text/javascript">
$(function(){
	$('.myform').idealforms();
	common.validator("menuform");
	$("#menuform").submit(function(){
		var param=$("#menuform").serialize();
		var canSubmit=common.checkBlankValue(param,new Array("menu.menuName","menu.url","menu.orderNo","menu.display","menu.parentId"));
		if(canSubmit){
			$.ajax({   
        		type: "POST",  
        		url: "${action }",  
        		data: param, 
        		success: function(msg){    
        			window.parent.closeDialog();
	        		var alertMsg="";
        			<c:if test="${addOperater}">
	        			if(msg=="success"){
	        				alertMsg="菜单添加成功！";
	        				$(window.parent.document).find("#myform").submit();
	        			}else if(msg=="exists"){
            				alertMsg="菜单ID已存在！";
            			}else{
            				alertMsg="菜单添加失败！";
            			}
        			</c:if>
        			<c:if test="${updateOperater}">
	        			if(msg=="success"){
	                    	alertMsg="菜单更新成功！";
	                    	$(window.parent.document).find("#myform").submit();
            			}else if(msg=="nochange"){
            				alertMsg="菜单属性没有改变！";
            			}else{
            				alertMsg="菜单更新失败！";
            			}
    				</c:if>
        			window.parent.editMenuTip(alertMsg);
        		} 
        	});
		}
		return false;
	});
});
</script>
</head>
	<body>
		<form action="${action }" name="menuform" class="myform"
			id="menuform" method="post">
			<input type="hidden" name="menu.menuId" value="${menu.menuId }">
			<div>
				<label class="required">
					菜单名称:
				</label>
				<input type="text" size="40" name="menu.menuName" value="${menu.menuName }" class="{required:true,messages:{required:'请输入菜单名称'}}"/>
			</div>
			<div>
				<label class="required">
					菜单URL:
				</label>
				<input type="text" size="40" name="menu.url" value="${menu.url }" class="{required:true,messages:{required:'请输入菜单URL'}}"/>
			</div>
			<div>
				<label class="required">
					排序值:
				</label>
				<input type="text" size="40" name="menu.orderNo" value="${menu.orderNo }" class="{required:true,digits:true,messages:{required:'请输入菜单URL'}}" />
			</div>
			<div>
				<label class="required">
					是否可用:
				</label>
				<select name="menu.display" class="{required:true,messages:{required:'请选择菜单是否可用'}}">
					<option value="">
						请选择
					</option>
					<option value="1" ${menu.display eq 1 ? 'selected':'' }>
						可用
					</option>
					<option value="0" ${menu.display eq 0 ? 'selected':'' }>
						不可用
					</option>
				</select>
			</div>
			<div>
				<label class="required">
					父菜单:
				</label>
				<select name="menu.parentId" class="{required:true,messages:{required:'请选择菜单的父菜单'}}">
					<option value="">
						请选择
					</option>
					<option value="0" ${menu.parentId eq 0 ? 'selected':''}>
						父菜单
					</option>
					<c:forEach items="${parentMenus }" var="item">
						<option value="${item.menuId }" ${menu.parentId eq item.menuId ? 'selected':'' }>
							${item.menuName }
						</option>
					</c:forEach>
				</select>
			</div>
			<div>
				<label>
					&nbsp;
				</label>
				<input type="submit" value="${btnKeyWord }" />
			</div>
		</form>
	</body>
</html>